package com.controller;

import com.base.BaseController;
import com.base.BasePageReq;
import com.base.BasePageRes;

import com.req.VipManageReq;
import com.res.UserRes;
import com.res.VipManageRes;
import com.service.VipManageService;
import com.util.common.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/vip/manage")
@RestController
@Api(tags = "vip用户")
public class VipManageController extends BaseController {
    @Autowired
    private VipManageService vipManageService;
    @PostMapping("/save")
    @ApiOperation("vip用户")
    public R<VipManageRes> saveVipUser(@RequestBody VipManageReq req){

        return R.ok(vipManageService.saveVipUser(req));
    }
    @PostMapping("/queryPage")
    @ApiOperation("vip用户分页查询")
    public R<BasePageRes> queryPage(@RequestBody BasePageReq req){
        UserRes user = this.getUser();
        return R.ok(vipManageService.queryPage(req,user));
    }

    @PostMapping("/open")
    @ApiOperation("开通vip")
    public R<VipManageRes> open(@RequestBody VipManageReq req){
        UserRes user = this.getUser();
        return R.ok(vipManageService.open(user,req));
    }
}
